package com.wgt.strategy.objSort.Test;

import com.wgt.strategy.objSort.Cat;
import com.wgt.strategy.objSort.ObjSort;

import java.util.ArrayList;
import java.util.List;
import java.util.Random;

/**
 * Created by wgt on 2017/7/20.
 */
public class CatTest {
    public static void main(String[] args) {
        //test1();
        //test2();
        test3();
    }


    public static void test1(){
        Cat cat1 = new Cat("tom",175,11);
        Cat cat2 = new Cat("tony",168,12);
        System.out.println(cat1.compareTo(cat2));
    }


    public static void test2(){
        //List<Cat> catList=  new ArrayList<Cat>();
        Cat[] cats = new Cat[10];
        for (int i=0;i<10;i++){
            cats[i]=new Cat("tom"+i, new Random().nextInt(100),new Random().nextInt(50));
        }
        System.out.println("原始的猫集合");
        for(int i=0;i<cats.length;i++){
            System.out.println(cats[i]);
        }
        System.out.println("////////////////////////");
        System.out.println("升序排序后的集合");
        ObjSort.sort(cats,ObjSort.ASC);
        for(int i=0;i<cats.length;i++){
            System.out.println(cats[i]);
        }
        System.out.println("////////////////////////");
        System.out.println("降序排序后的集合");
        ObjSort.sort(cats,ObjSort.DESC);
        for(int i=0;i<cats.length;i++){
            System.out.println(cats[i]);
        }
    }



    public static void test3(){
        List<Cat> catList=  new ArrayList<Cat>();
        for (int i=0;i<10;i++){
            catList.add(new Cat("tom"+i, new Random().nextInt(100),new Random().nextInt(50)));
        }
        System.out.println("原始的猫集合");
        for(int i=0;i<catList.size();i++){
            System.out.println(catList.get(i));
        }
        System.out.println("////////////////////////");
        System.out.println("升序排序后的集合");
        ObjSort.sort(catList,ObjSort.ASC);
        for(int i=0;i<catList.size();i++){
            System.out.println(catList.get(i));
        }
        System.out.println("////////////////////////");
        System.out.println("降序排序后的集合");
        ObjSort.sort(catList,ObjSort.DESC);
        for(int i=0;i<catList.size();i++){
            System.out.println(catList.get(i));
        }
    }
}
